package com.example.demo.util;

/***
 * 格式校验
 * <p>
 *@author zhangshuai
 *@date 2021-04-01-11-06
 *@Version 1.0
 */
public class CheckFormat {


    public static boolean isPhone(String username) {
        return username.matches("((\\+86|0086)?\\s*)((134[0-8]\\d{7})|(((13([0-3]|[5-9]))|(14[5-9])|15([0-3]|[5-9])|(16(2|[5-7]))|17([0-3]|[5-8])|18[0-9]|19(1|[8-9]))\\d{8})|(14(0|1|4)0\\d{7})|(1740([0-5]|[6-9]|[10-12])\\d{7}))");
    }

    public static boolean isEmail(String username) {
        return username.matches("^([a-z0-9A-Z]+[-|\\.]?)+[a-z0-9A-Z]@([a-z0-9A-Z]+(-[a-z0-9A-Z]+)?\\.)+[a-zA-Z]{2,}$");
    }
}
